package pers.liyan.shi.manager.client.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import pers.liyan.shi.manager.client.NASClient;
import pers.liyan.shi.manager.common.Result;
import pers.liyan.shi.manager.configuration.NASProperties;

/**
 * @author ShiLY
 * @version 1.0
 * @date 2020/3/28 23:01
 */
@Service
public class NASClientImpl implements NASClient {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private NASProperties nasProperties;

    @Override
    public Result shutDown() {
        return restTemplate.postForObject(nasProperties.getShutdownUrl(), null, Result.class);
    }

    @Override
    public Result restart() {
        return restTemplate.postForObject(nasProperties.getRestartUrl(), null, Result.class);
    }

    @Override
    public Result cancel() {
        return restTemplate.postForObject(nasProperties.getCancelUrl(), null, Result.class);
    }
}
